package com.example.demo.module.aop.controller;

import com.example.demo.code.aop.annotation.Action;
import com.example.demo.module.aop.entity.Car;
import org.springframework.web.bind.annotation.*;

/**
 * 切面控制器
 *
 * @author huangchenyu
 * @date 2021-03-31
 */
@RestController
@RequestMapping("aspect")
public class AspectController {

    /**
     * test1
     *
     * @return {@link String}
     */
    @Action(description = "执行菜单操作")
    @PostMapping("/test1")
    public String test1(@RequestBody Car car) {
        System.out.println("--------->执行菜单操作");
        return "nice";
    }

    /**
     * 走切面，抛异常
     */
    @GetMapping("/throws")
    @Action(description = "执行了throws菜单但是抛了异常")
    public void throwsException(){
        System.out.println("------------->执行了throws菜单但是抛了异常");
        throw new RuntimeException();
    }
}
